import type { StepMaterialModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 获取工艺物料数据集合
 * @param stepId 工艺步骤 Id
 * @returns 返回查询结果
 */
export async function getStepMaterialListApi(stepId: number) {
  return requestClient.get<StepMaterialModel[]>(
    '/mes/process/stepMaterial/list',
    {
      params: { stepId },
    },
  );
}

/**
 * 创建工艺物料
 * @param data 要创建的工艺物料
 * @returns 返回结果
 */
export async function createStepMaterialApi(data: any) {
  return requestClient.post<boolean>('/mes/process/stepMaterial', data);
}

/**
 * 更新工艺物料
 * @param id 工艺物料 Id
 * @param data 要更新的工艺物料
 * @returns 返回结果
 */
export async function updateStepMaterialApi(id: number, data: any) {
  return requestClient.put<boolean>(`/mes/process/stepMaterial/${id}`, data);
}

/**
 * 删除工艺物料
 * @param id 工艺物料 Id
 * @returns 返回结果
 */
export async function deleteStepMaterialApi(id: number) {
  return requestClient.delete<boolean>(`/mes/process/stepMaterial/${id}`);
}
